package com.cgx.tablet.beeper.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.cgx.tablet.beeper.activity.LoginActivity;

/**
 * Created by Administrator on 2018/9/9 0009.
 * 开机自启动
 */

public class BootBroadcastReceiver extends BroadcastReceiver{

    static final String BOOT_ACTION = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("BOOT_ACTION1", BOOT_ACTION);
        if (intent.getAction() != null && intent.getAction().equals(BOOT_ACTION)) {
            Log.d("BOOT_ACTION2", BOOT_ACTION);
            Intent mainActivityIntent = new Intent(context, LoginActivity.class);  // 要启动的Activity
            mainActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mainActivityIntent);
        }
    }
}
